﻿using System;

namespace Taste.Internal
{
    internal class StateError<TState> : IStateError<TState>
        where TState : struct
    {
        public StateError(Exception error)
        {
            this.IsHandled = false;
            this.Error = error;
        }

        public Exception Error { get; set; }
        public bool IsHandled { get; set; }
        public TState NextStateName { get; set; }
        public object NextUserData { get; set; }

        public void HandleError(TState nextStateName, object nextUserData = null)
        {
            this.IsHandled = true;
            this.NextStateName = nextStateName;
            this.NextUserData = nextUserData;
        }
    }
}
